package atag;

import atag.common.ATaGProgram;
import atag.gui.MainFrame;
import org.apache.log4j.*;

import javax.swing.*;
import java.io.*;
import Tools.Executer;
import Tools.ExecuterStandard;
import atag.compiler.ATaGParser;

/**
 * Created by IntelliJ IDEA.
 * User: home
 * Date: Jan 21, 2011
 * Time: 3:27:03 PM
 * To change this template use File | Settings | File Templates.
 */
public class SrijanFactory {

    ATaGProgram atg_program = new ATaGProgram();
    static MainFrame m_frame;

    public ATaGProgram getAtg_program() {
        return atg_program;
    }

    public void setAtg_program(ATaGProgram atg_program) {
        this.atg_program = atg_program;
    }

    public static MainFrame getM_frame() {
        return m_frame;
    }

    public static void setM_frame(MainFrame m_frame) {
        SrijanFactory.m_frame = m_frame;
    }

    public SrijanFactory(ATaGProgram atg_program) {
        this.atg_program = atg_program;
        m_frame = new MainFrame(getAtg_program());
    }

    //this main is to test the application separetely from the eclipse plugin
    public static void main(String[] args) {

        Logger logger = Logger.getLogger(SrijanFactory.class);

        ATaGProgram als;
        if (args.length > 0) {
            als = ATaGParser.parseATaGProgram(args[0] + File.separator+ "TaskGraph.xml"); 
            als.sanitize();
        } else {
            als = new ATaGProgram();
        }

        String[] compilerArgs = {args[0] + File.separator+ "TaskGraph.xml",
            args[0] +  File.separator+ "NetworkDescription.txt",
            args[1],
            "random",
            "0",
            args[0]};

        atag.compiler.Main.main(compilerArgs,
                als);

    }
}
